<template>
  <a-modal
    :maskClosable="false"
    :keyboard="false"
    title="授权信息"
    :width="600"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel">
    <template slot="footer">
      <a-button key="close" @click="handleCancel">{{ $t('m.common.button.close') }}</a-button>
      <a-button key="ok" type="primary" @click="updateLic">更新授权</a-button>
    </template>

    <a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol">
      <a-form-model-item label="版本类型" prop="versionType">
        {{form.versionTypeLabel}}
      </a-form-model-item>
      <a-form-model-item label="客户名称" prop="customer">
        {{form.customer}}
      </a-form-model-item>
      <a-form-model-item label="到期时间" prop="times">
        {{form.times}}
      </a-form-model-item>
      <a-form-model-item label="用户数" prop="users">
        {{form.users}}
      </a-form-model-item>
      <a-form-model-item label="表单数" prop="forms">
        {{form.forms}}
      </a-form-model-item>
      <a-form-model-item label="流程数" prop="processes">
        {{form.processes}}
      </a-form-model-item>
      <a-form-model-item label="存储空间" prop="files">
        {{form.files}}G
      </a-form-model-item>
      <a-form-model-item label="模块列表" prop="modules">
        {{form.modules}}
      </a-form-model-item>
    </a-form-model>

  </a-modal>
</template>

<script>

  import { getAction } from '@/api/manage'
  import YchConstant from "@/api/YchConstant";

  export default {
    name: 'LicInfo',
    data () {
      return {
        visible: false,
        confirmLoading: false,
        form: {},
        labelCol: {
          span: 6
        },
        wrapperCol: {
          span: 16
        },
        url: {
          querySysConfigLic: YchConstant.PREFIX_SYSTEM + '/sysconfig/querySysConfigLic',
          queryMacStr: YchConstant.PREFIX_SYSTEM + '/sysconfig/queryMacStr',
          updateConfigLic: YchConstant.PREFIX_SYSTEM + '/sysconfig/updateConfigLic',
        }
      }
    },
    methods: {
      show () {
        this.visible = true
        this.confirmLoading = true
        getAction(this.url.querySysConfigLic).then((res) => {
          if (res.success) {
            this.form = res.result
          } else {
            this.messageUtil.warning(res.message)
          }
        }).catch(() => {
          this.messageUtil.warning('查询数据失败')
        }).finally(() => {
          this.confirmLoading = false
        })
      },
      handleCancel () {
        this.visible = false
      },
      updateLic () {
        this.handleCancel()
        this.$emit('updateLic')
      },
    }
  }
</script>
